JQuery serialize () serializeArray (), jquery form serialization
1. serialize () method
Format: var data = $ ("form"). serialize ();
Function: serialize the form content into a string.
In this way, when submitting form data through ajax, you do not
In jquery Ajax, data is sent to the server in the form of a key-value pair (Key/value), which can be serialized as a key-value pair using the jquery Ajax Serialize () method form when submitting form data using AJAX (key1=value1&key2= Value2 ... )
1.serialize () methodFormat: var data = $ ("form"). Serialize ();Function: Serializes the contents of the form into a single string.This way, when Ajax submits the form data, it is not necessary to enumerate each parameter. Simply set the data
Serialized data
--Example program: memo
Create a new single-document SDI application. Select cformview for the View class so that you can enter it in the window. Create three edit boxes on the page, and then add three corresponding edit box
In jquery, we can directly use serialize () to convert ajax submitted forms. In this way, the input in the form name is converted to the get method. If we have a large number of parameters, we do not need to fill them out.
Data in jQuery ajax is
The Ajax serialize () form is serialized to upload files and serialize is serialized.
Upload files using the traditional form submission method
upload a file:
However, the traditional form submission will refresh the page, but in some cases,
The serialize () serialization of jquery is a simple introduction:In jquery, when using Ajax, it is often necessary to assemble input data to be sent to the server in the form of a key-value pair (key/value).The Serialize method can do this easily,
When submitting a form through jquery Ajax, the form content is usually obtained in the following way.varform = ' Add-account-form '; //form ID $ (' # ' + form). Submit (function() {varAccount = { ' user_id ': ',
The serialize () method of query creates a URL-encoded text string by serializing the form value, and we can select one or more form elements, or you can directly select the form to serialize it, such as:first Name: last Name: $ (document). Ready
jquery's Serialize () method creates a URL-encoded text string by serializing the form value, we can select one or more form elements, or you can directly select the form to serialize itfirst Name: last Name: $ (document). Ready (function () {
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.